<?php
require_once 'BaseController.php';

class Admin_IndexController extends BaseController {
	
	//后台首页
	public function indexAction() {
		try{
			//获取数据库大小
			$db_total = 0;
			$db_status = $this->orm->query('SHOW TABLE STATUS FROM ' . __DEFAULTDBNAME__);
			
			foreach($db_status as $v) {
				$db_total += $v['Data_length'] + $v['Index_length'];
			}
			$db_size = array('B','K','M','G');
			$i = 0;
			while($db_total > 1024) {
				$db_total /= 1024;
				if(++$i >= 3) {
					break;
				}
			}
			$db_total = sprintf('%.2f',$db_total);
			$db_total = $db_total . $db_size[$i];
			
			$this->view->assign(array(
				'userInfo'		=> $this->orm->createDAO('_users_info')->findUser_id($this->admin_info['uid'])->get(),
				'wd_version'	=> $this->sysConfig['default']['version'],
				'uc_version'	=> 'UCenter ' . UC_CLIENT_VERSION . ' Release ' . UC_CLIENT_RELEASE,
				'mysql_version'	=> $this->orm->query('SELECT VERSION() as version'),
				'db_total'		=> $db_total
			));
			
			echo $this->view->render('index/index.htm');
			exit;
		}catch(Exception $e) {
			$this->toErrorLogs($e);
			$this->alert_go(addslashes($e->getMessage()),__PROJECTNAME__ . '/admin');
		}
	}
	
	//删除消息
	public function messageBoxAction() {
		try{
			uc_pm_location($this->admin_info['uid']);
		}catch(Exception $e) {
			$this->toErrorLogs($e);
			$this->alert_go(addslashes($e->getMessage()),__PROJECTNAME__ . '/admin');
		}
	}
}

